<script>
    $(function () {
    $.messager.model = {ok:{ text: "确定"},cancel: { text: "取消"}};
    $(".delete_btn").click(function () {
                var datas = $(this).data("url");
                $.messager.confirm("温馨提示","亲,真的要删除嘛!", function() {
                    $.get(datas,function () {
                       doSucceed();
                    });
                });

            });

    });

    //操作成功后的提示
    function doSucceed() {
        $.messager.alert("操作成功", "2秒后自动关闭");
        setTimeout(function () {
            location.reload();
        },1024);
    }

    //可选菜单移动
    function moveAll(src,target){
        $("." + src + " option").appendTo("."+target);
    }
    function moveSelected(src,target){
        $("." + src + " option:selected").appendTo("."+target);
    }
    $(function () {
        var role;
        //去重
        $(".selfSelect option").each(function (index, ele) {
            $(".allSelect option[value='" + ele.value + "'").remove();
        });

        //表单提交前选中右下拉菜单
        $("#btn_submit").click(function () {
            $(".selfSelect option").prop("selected", true);
            $.messager.confirm("温馨提示", "是否真的保存", function () {
                $("#editForm").submit();
                doSucceed();
            });
        });
    });

    //移交
    $(function () {
        $(".transferAnyBtn").click(function () {
            $("#transferForm").val("");
            backPlay(this);
            $("#transferForm select[name='newSeller.id']").prop("disabled",false);
        });

        $(".transferSubmitBtn").click(function () {
            $("#transferForm select[name='newSeller.id']").prop("disabled",false);
            $("#transferForm").submit();
        });
    });
    function backPlay(src) {
        var json = $(src).data("json");
        $("select[name='newSeller.id']").html("");
        $.get("/employee/emps.do",{"id":json.sellerId},function (data) {
            $.each(data,function (index,ele) {
                $("<option value="+ele.id+">"+ele.name+"</option>").appendTo("select[name='newSeller.id']");
            });
            $("select[name='newSeller.id']").val("<@shiro.principal property='id'/>");
        },"json");
        $("#transferForm input[name='customer.id']").val(json.id);
        $("#cName").val(json.name);
        $("#transferForm input[name='oldSeller.id']").val(json.sellerId);
        $("#oldSeller").val(json.sellerName);
        $("#transferModal").modal("show");
    }
</script>